<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../../static/admin/layui/css/layui.css"
	media="all">
<!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
	<div class="layui-left" style="margin-left: 50px">
		<!-- 内容主体区域 -->
		<br>
		<h1 style="padding-left: 100px">添加商品</h1>
		<hr>
		<form class="layui-form" action="addcloth" method="post" enctype="multipart/form-data" >
			<div class="layui-form-item">
				<label class="layui-form-label">上传图片</label><br>
				<div class="layui-input-block">
					<input type="file" name="file">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商品编号</label>
				<div class="layui-input-block">
					<input type="text" name="cloth_id" style="width: 300px;" autocomplete="off"
						placeholder="请输入商品编号" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商品名称</label>
				<div class="layui-input-block">
					<input type="text" name="cloth_name" style="width: 300px;" autocomplete="off"
						placeholder="请输入商品名称" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商品价格</label>
				<div class="layui-input-inline">
				    <input type="text" name="price" style="width: 300px;" autocomplete="off"
						placeholder="请输入价格" class="layui-input">
					<!--  <select name="modules" id="price" lay-verify="required"
						lay-search="">
						<option value="">直接选择或搜索选择</option>
					</select>-->
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">进货总数量</label>
				<div class="layui-input-block">
					<input type="text" name="total_count" style="width: 300px;" autocomplete="off"
						placeholder="请输入进货总数" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">选择商品种类</label>
				<div class="layui-input-block">
					<div style="width: 300px;">
						<select name="type_id" id="type"></select>
					</div>
					<!--  <div style="width: 300px;">
						<select id="detils" style="width: 300px;"></select>
					</div>-->
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">尺寸大小</label>
					<div class="layui-input-block" style="width: 300px;">
						<select name="size_id" id="size" ></select>
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商品颜色</label>
				<div class="layui-input-block" style="width: 300px;">
					<select name="color_id" id="color" ></select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">输入数量</label>
				<div class="layui-input-block">
				   <input name="size_count" type="text" style="width: 300px;" placeholder="请输入数量" class="layui-input">
					<!--<table class="layui-table" id="sc" lay-filter="test">
						<tr>
							<td>尺码</td>
							<td>颜色</td>
							<td>数量</td>
							<td>操作</td>
						</tr>
					</table>-->
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" class="layui-btn" lay-submit=""
						lay-filter="demo1">立即提交</button>
				</div>
			</div>

		</form>
	</div>
	<script src="../../static/admin/layui/layui.all.js"
		type="text/javascript" charset="utf-8"></script>
	<script src="../../static/admin/js/common.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="../../static/admin/js/main.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="../../static/admin/js/jquery-3.4.1.js"
		type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function() {
			/*var array = new Array();
			for (var i = 10; i < 500; i++) {
				array.push(i);
			}
			$.each(array, function(i, value) {
				$('#price').append(
						"<option name='price', value="+value+">" + value
								+ "</option>");
			});*/
		/*	var type = [ "请选择", "上衣", "外套" ];
			type["上衣"] = [ "请选择", "半袖", "毛衣", "针织衫" ];
			type["外套"] = [ "请选择", "毛衣外套", "羽绒服", "牛仔外套" ];
			type["请选择"] = [ "请选择" ];
			$.each(type, function(i, o) {
				$("#type").append("<option value="+o+">" + o + "</option>");
			});
			$("#type").change(
					function() {
						$("#detils").get(0).options.length = 0;
						$.each(type[this.value], function(i, o) {
							$("#detils").append(
									"<option value="+o+">" + o + "</option>");
						});
					});*/
			
					$.ajax({
						url : "gettypeoneinfo",
						type : "get",
						success : function(data) {
							console.log(data);
							$.each(data, function(i, value) {
								$("#type").append(
										"<option name='type', value="+value.type_oneid+">" + value.type_onename
										+ "</option>"	
								);
							});
							layui.use('form', function() {
								var form = layui.form;
								form.render();
							});
						},
						dataType : "json"
					});
		});
	</script>
	<script type="text/javascript">
		$(function() {
			$.ajax({
				url : "getclothsize",
				type : "get",
				success : function(data) {
					console.log(data);
					$.each(data, function(i, value) {
						$("#size").append(
								"<option name='price', value="+value.size_id+">" + value.cloth_size
								+ "</option>"	
						);
					});
					layui.use('form', function() {
						var form = layui.form;
						form.render();
					});
				},
				dataType : "json"
			});
			
			$.ajax({
				url : "getcolor",
				type : "get",
				success : function(data) {
					console.log(data);
					$.each(data, function(i, value) {
						$("#color").append(
								"<option name='price', value="+value.color_id+">" + value.color_name
								+ "</option>"		
						);
					});
					layui.use('form', function() {
						var form = layui.form;
						form.render();
					});
				},
				dataType : "json"
			});
					/*var arr1 = new Array();
					var arr2 = new Array();
							$("input[name=size]:checked").each(function (key, value) {
							　　　　　　arr1.push($(value).val());
							　　　　});
						　　　　$("input[name=color]:checked").each(function (key, value) {
						　　　　　　arr2.push($(value).val());
						　　　　});
						console.log(arr2);
					$.each(arr1, function(i1, value1) {
						$.each(arr2, function(i2, value2) {
							$("#sc").append('<tr> ' +
									'<td>' + value1 + '</td>' + 
									'<td>' + value2 + '</td>' +
									'<td> <input type="text" style="width: 200px;" placeholder="请输入数量" class="layui-input">  </td>' +
									'<td> <a>删除</a> </td>'+
									'</tr>')
						});
					});	*/

				
			
		});
	</script>

</body>
</html>